package com.hy.activiti.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.pagehelper.Page;
import com.hy.framework.web.page.PageDomain;
import com.hy.project.activiti.domain.dto.DefinitionIdDTO;
import com.hy.project.activiti.domain.dto.ProcessDefinitionDTO;
import org.activiti.engine.repository.Model;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

/**
 * 汇讯数码科技(深圳)有限公司
 * 创建日期:2020/10/22-16:34
 * 版本   开发者     日期
 * 1.0    Danny    2020/10/22
 */
public interface IProcessDefinitionService {
    /**
     * 获取流程定义集合
     * @param processDefinition
     * @return Page 分页信息
     */
    public Page<ProcessDefinitionDTO> selectProcessDefinitionList(ProcessDefinitionDTO processDefinition, PageDomain pageDomain);
    public DefinitionIdDTO getDefinitionsByInstanceId(String instanceId);

    /**
     * 获取流程实例集合
     * @param ProcessInstance
     * @return Page 分页信息
     */
    public Page<ProcessInstance> selectProcessRunningList(ProcessInstance processInstance, PageDomain pageDomain) ;

    /**
     * 流程模型列表
     */
    public Page<Model> selectModelList(org.activiti.engine.repository.Model model, PageDomain pageDomain)    ;

    /**
     * 读取资源，通过部署ID
     * @param processDefinitionId  流程定义ID
     * @param processInstanceId 流程实例ID
     * @param resourceType 资源类型(xml|image)
     */
    public InputStream resourceRead(String procDefId, String proInsId, String resType) throws Exception;

    /**
     * 删除流程定义
     * @param id
     * @return
     */
    public int deleteProcessDefinitionById(String id);
    /**
     * 上传并部署流程定义
     * @param file
     * @return
     * @throws IOException
     */
    public void uploadStreamAndDeployment(MultipartFile file) throws IOException;
    /**
     * 启动挂起流程流程定义
     * @param id 流程定义id
     * @param suspendState 流程状态
     * @return
     */
    public void suspendOrActiveApply(String id, Integer suspendState);

    /**
     * 上传流程流程定义
     * @param multipartFile
     * @return
     */
    public String upload(MultipartFile multipartFile) throws IOException;
    /**
     * 通过stringBPMN添加流程定义
     * @param stringBPMN
     * @return
     */
    public void addDeploymentByString(String stringBPMN );

    /**
     * 获取流程定义XML
     * @param response
     * @param deploymentId
     * @param resourceName
     */
    public void getProcessDefineXML(HttpServletResponse response, String deploymentId,String resourceName) throws IOException;

    /**
     * 创建模型
     * @throws UnsupportedEncodingException
     */
    public Model create(String name, String key, String description, String category) throws UnsupportedEncodingException;

    /**
     * 删除模型
     * @param id
     * @return
     */
    public int deleteModelById(String id);

    /**
     * 导出model的xml文件
     * @throws IOException
     * @throws JsonProcessingException
     */
    public void exportModelById(HttpServletResponse response, String modelId);

    /**
     * 根据Model部署流程
     */
    public String deploy(String id);
}
